package com.wdc.Map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HashMap01  {
    public static void main(String[] args) {

        HashMap<String, String> map = new HashMap<>();
        map.put("wdc", "123");
        map.put("lq", "321");



        Iterator<String> iterator = map.keySet().iterator();








        new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            map.put("lisi", "wangshu");
        }).start();

        new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            map.put("asd", "asd");
        }).start();

        new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            map.put("qwe", "qwe");
        }).start();


        while (iterator.hasNext()) {
            String key = iterator.next();
            String value = map.get(key);
            System.out.println("key : " + key + " value " + value);

        }


    }
}
